package cn.windfly.demo.config;

import java.util.ArrayList;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.GetMapping;

import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

	@Bean
	public Docket docket() {
		ApiInfo apiInfo = new ApiInfo("Api demo", "demo api", "v1.0", "",
				new Contact("windfly", "http://windfly.cn", "thoughfly@qq.com"), "Apache 2.0",
				"http://www.apache.org/licenses/LICENSE-2.0", new ArrayList<VendorExtension>());
		
		return new Docket(DocumentationType.SWAGGER_2)
				.enable(true)
				.groupName("demo1")
				.apiInfo(apiInfo)
				.select()
				.apis(RequestHandlerSelectors.basePackage("cn.windfly.demo"))
				.paths(PathSelectors.ant("/api/**"))
				.build();
	}
	@Bean
	public Docket docket1() {
		return new Docket(DocumentationType.SWAGGER_2)
				.enable(true)
				.groupName("demo2")
				.apiInfo(new ApiInfo("Api demo2", "demo api2", "v1.0", "",
						new Contact("windfly", "http://windfly.cn", "thoughfly@qq.com"), "Apache 2.0",
						"http://www.apache.org/licenses/LICENSE-2.0", new ArrayList<VendorExtension>())
						).select()
				.apis(RequestHandlerSelectors.withClassAnnotation(GetMapping.class))
				.paths(PathSelectors.ant("/api/**"))
				.build()
				
				;
	}
}
